import 'package:core/core.dart';
import 'package:core/ui/base/base_material_app.dart';
import 'package:core_demo/helper/config/route.dart';
import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return BaseMaterialApp(
      title: 'core demo',
      initialRoute: RouteName.home,
      routeList: routes,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter(context) {
    // print('screenWidth:${DeviceHelper.screenWidth}');
    // print('screenHeight:${DeviceHelper.screenHeight}');
    // print('topBarHeight:${DeviceHelper.topBarHeight}');
    // print('botBarHeight:${DeviceHelper.botBarHeight}');
    // print('keyboardHeight:${DeviceHelper.keyboardHeight}');
    // ToastHelper.showNotification('hahaha');
    // CoreNavigatorObserver.showHistory();
    NavigatorHelper.pushNamed(context, RouteName.first, arguments: {});
    // DialogHelper.showBottomSheet(child: Text('这是sheet'), height: 200.px);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text('widget.title'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: Builder(
        builder: (c) => FloatingActionButton(
          onPressed: () => _incrementCounter(c),
          tooltip: 'Increment',
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}
